package com.warm.base.algorithm.sort;

import com.google.common.base.Stopwatch;

import java.util.concurrent.TimeUnit;

import static com.warm.base.algorithm.sort.AbstractAscSort.show;

public class SortCompare {

    public static void main(String[] args) {

    }

    private static void sort(){
        Integer[] a = {4, 1, 3, 4, 5, 6, 0, 2}; // Integer 等包装类底层实现了 Comparable 接口
        //AbstractAscSort sort = new SelectionAscSort();
        AbstractAscSort sort = new Insertion();
        sort.sort(a);
        show(a);
    }

    public static double time(String sortName, Comparable[] a){
        Stopwatch timer= Stopwatch.createStarted();
        if ("Selection".equals(sortName)) new Selection().sort(a);
        if ("Insertion".equals(sortName)) new Insertion().sort(a);

        return timer.elapsed(TimeUnit.NANOSECONDS);
    }

    /*public static double timeRandomInput(String alg, int N, int T) {
        double total = 0.0;
        Double[] a = new Double[N];
        for (int i = 0; i < T; i++) {
            for (int j = 0; j < N; j++) {
                a[j] = StdRandom
            }
        }
    }*/
}
